package com.situ.company.controller;

import com.situ.company.entity.Dept;
import com.situ.company.service.Impl.DeptService;
import com.situ.company.service.Impl.service.Impl.DeptServiceImpl;
import com.situ.company.vo.ResultVO;
import com.situ.company.vo.TableVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/dept")
public class DeptController extends BaseController{

    DeptService service = new DeptServiceImpl();
    //打开页面
    public void page(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //查数据,带上
        req.getRequestDispatcher("/WEB-INF/dept.jsp").forward(req,resp);
    }

    public List<Dept> all(){
        return service.all();
    }

    public TableVO select(Integer page, Integer limit, String name, String tel) {

        //查出来商品的数据
        return service.select(page,limit,name,tel);


        //把数据返回给table小工具(响应)
        //获取一个响应的前台写出对象
        //list转完后是[{},{},{}]




    }
    public void save(Dept d){
        service.save(d);

    }

    public ResultVO delete(Integer id){
        //检查一下是否已经被使用

     return   service.delete(id);
    }


    //编辑
    public  Dept info(Integer id) {

        return service.info(id);
    }



}